/*
消息主体类
包含内容：
    时间戳
    日志等级
    文件名
    行号
    线程ID
    日志器名称
    消息主体
*/

#ifndef MESSAGE_HPP
#define MESSAGE_HPP

#include "level.hpp"
#include "util.hpp"
#include <iostream>
#include <string>
#include <ctime>
#include <thread>

namespace xzt
{
    namespace log
    {
        class LogMsg
        {
        public:
            LogMsg(const std::string& filename, size_t line, Level::value level,
                const std::string& loggerName,  const std::string& payload):
                _timestamp(util::Date::now()), _threadId(std::this_thread::get_id()),
                _filename(filename), _line(line), _loggerName(loggerName), _level(level), _payload(payload)
                {}
            
            time_t getTimeStamp() const
            {
                return _timestamp;
            }
            Level::value getLevel() const
            {
                return _level;
            }
            const std::string& getFilename() const
            {
                return _filename;
            }
            size_t getLine() const
            {
                return _line;
            }
            const std::thread::id& getThreadId() const
            {
                return _threadId;
            }
            const std::string& getLoggerName() const
            {
                return _loggerName;
            }
            const std::string& getPayload() const
            {
                return _payload;
            }
            
        private:
            time_t _timestamp;  // 时间戳(type: long)
            Level::value _level;
            std::string _filename;
            size_t _line;
            std::thread::id _threadId;
            std::string _loggerName;  // 日志器名称
            std::string _payload;  // 消息主体
        };
    }
}


#endif